package artid.com.arttogoa.adapter;

import java.util.List;
import artid.com.arttogoa.R;
import artid.com.arttogoa.parser.LogisticsInfoParser;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * 
 *    
 * 项目名称：ArtworkArtA   
 * 类名称   ：LogisticsInfo_Adapter   
 * 类描述   ：物流信息适配器   
 * 创建人   ：耿卫斌   
 * 创建时间：2016-7-27 上午11:29:18   
 *
 */
public class LogisticsInfo_Adapter extends BaseAdapter{
	private Context mContext;
	private List<LogisticsInfoParser> list;

	public LogisticsInfo_Adapter(Context mContext,
			List<LogisticsInfoParser> list) {
		super();
		this.mContext = mContext;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		//		return list.size();
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		View v = convertView;
		if (v == null) {
			holder = new ViewHolder();
			v = LayoutInflater.from(mContext).inflate(R.layout.item_logisticsinfo, null);
			holder.oneLL=(LinearLayout) v.findViewById(R.id.item_logisticsinfo_oneLL);
			holder.middleLL=(LinearLayout) v.findViewById(R.id.item_logisticsinfo_middleLL);
			holder.oneTitle=(TextView) v.findViewById(R.id.item_logisticsinfo_oneTitle);
			holder.oneTime=(TextView) v.findViewById(R.id.item_logisticsinfo_oneTime);
			holder.middleTitle=(TextView) v.findViewById(R.id.item_logisticsinfo_MiddleTitle);
			holder.middleTime=(TextView) v.findViewById(R.id.item_logisticsinfo_MiddleTime);
			v.setTag(holder);
		} else {
			holder = (ViewHolder) v.getTag();
		}
		if(position==0){
			holder.oneLL.setVisibility(View.VISIBLE);
			holder.middleLL.setVisibility(View.GONE);
			holder.oneTitle.setText(list.get(position).getContext());
			holder.oneTime.setText(list.get(position).getTime());
		}else{
			holder.oneLL.setVisibility(View.GONE);
			holder.middleLL.setVisibility(View.VISIBLE);
			holder.middleTitle.setText(list.get(position).getContext());
			holder.middleTime.setText(list.get(position).getTime());
		}
		return v;
	}
	class ViewHolder {
		LinearLayout oneLL,middleLL;
		TextView oneTitle,oneTime,middleTitle,middleTime;
	}
}
